<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
	<link rel="stylesheet" type="text/css" href="../layui/css/layui.css"/>
	<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/axios.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../lib/jquery-3.6.0.js" type="text/javascript" charset="utf-8"></script>
	
	<style type="text/css">
		#app{
			padding: 30px 20px;
		}
	</style>
</head>
<body>
<h1>老师界面</h1>
<div id="app">
	<div class="layui-btn-container">
	  <button class="layui-btn layui-btn-primary layui-border-green" @click="getinformation()">查询个人信息</button>
	   
	  <button class="layui-btn layui-btn-primary layui-border-blue" @click="getcurriculum()">查询任课班级</button>
	</div>

	<div id="teaccherinformation" >
		<div class="layui-bg-gray" style="padding: 30px;">
		  <div class="layui-row layui-col-space15">
		    <div class="layui-col-md6" v-show="showinformation==1">
		      <div class="layui-panel">
		        <div style="padding: 50px 30px;">
					<!-- <p><span>名字:</span><span id="name">张三</span></p>
					<p><span>性别:</span><span id="sex">男</span></p>
					<p><span>年龄:</span><span id="age">19</span></p>
					<p><span>生日:</span><span id="birthday">1-1</span></p>
					<p><span>工资:</span><span id="wages">1000</span></p> -->
					
					
					<div id="appp">
						<div class="layui-form layuimini-form">
						    <div class="layui-form-item">
						        <label class="layui-form-label required">用户名</label>
						        <div class="layui-input-block">
						            <input type="text" v-model="user.uname" name="username" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
						            
						        </div>
						    </div>
							
						    <div class="layui-form-item">
						        <label class="layui-form-label required">性别</label>
						        <div class="layui-input-block">
						            <input type="radio" name="sex" v-model="user.sex" value="1" title="男" checked="">
						            <input type="radio" name="sex" v-model="user.sex" value="2" title="女">
						        </div>
						    </div>
							
							
							<div class="layui-form-item">
							    <label class="layui-form-label">年龄</label>
							    <div class="layui-input-block">
							        <input type="text" name="age" v-model="user.age" placeholder="请输入年龄" value="" class="layui-input">
							    </div>
							</div>
							<div class="layui-form-item">
							    <label class="layui-form-label">姓名</label>
							    <div class="layui-input-block">
							        <input type="text" name="name" v-model="user.name" placeholder="请输入名字" value="" class="layui-input">
							    </div>
							</div>
							
							<div class="layui-form-item">
							    <label class="layui-form-label">生日</label>
							    <div class="layui-input-block">
							        <input type="text" v-model="user.birthday" name="birthday" placeholder="请输入生日" value="" class="layui-input">
							    </div>
							</div>
							<div class="layui-form-item">
							    <label class="layui-form-label">工资</label>
							    <div class="layui-input-block">
							        <input type="text" v-model="user.weges" name="birthday" placeholder="工资只能看不能修改" value="" class="layui-input">
							    </div>
							</div>
							
						
						    <div class="layui-form-item">
						        <div class="layui-input-block">
						            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn" @click="modify()">确认保存</button>
						        </div>
						    </div>
						</div>
					</div>
					
					
				</div>
		      </div>   
		    </div>
			<!-- 查询任课班级页面 -->
		    <div class="layui-col-md6" v-show="showcurriculum==1" style="cursor:pointer ;">
		      <div class="layui-panel">
		        <div style="padding: 50px 30px;" v-for="(item,i) in banji">{{item}}</div>
		      </div>   
		    </div>
		  </div> 
		</div>
		
		
</div>


</div>
<script type="text/javascript">
	new Vue({
		el:'#app',
		data:{
			
			banji:['网络本18','物联本18'],
			showinformation:0,
			showcurriculum:0,
			user:{
				id:'',
				uname:'',
				password:'',
				name:'',
				sex:'',
				age:'',
				birthday:'',
				weges:''
			}
		},
		methods:{
			
			getinformation(){
				this.showcurriculum=0,
				this.showinformation=1,
				
				// 获取老师信息
				
				axios
				.get('http://localhost:8080/judgeLogin.action')
				.then(res=>{
								 console.log(res.data)
								 this.user=res.data
								 if(res.data.sex=='男')
								 {
									 this.user.sex='1'
								 }
								 else  if(res.data.sex=='女')
								 {
									 this.user.sex='2'
								 }
								 console.log(this.user.sex)
								 
								
				})
				
			},
			//修改方法
			modify(){
				$.ajax({
					
				    url:'http://localhost:8080/modify.action',
				    type:'post',
				    dataType:'text',
				    // data:JSON.stringify({user:this.user}),  
					data:{
						id:this.user.id,
						uname:this.user.uname,
						name:this.user.name,
						sex:this.user.sex,
						age:this.user.age,
						birthday:this.user.birthday
						
					},
					success:function(msg){
				    if(msg=='ok')
						{
							alert("修改成功！下次登录生效")
						}
						else{
							alert("修改失败")
						}
				  }
				})
				// this.getUser()
			},
			//点击班级之后查询全班信息
			getcurriculum(){
				this.showinformation=0,
				this.showcurriculum=1,
		 		$.ajax({
		 		    url:'http://localhost:8080/getTeacherClass.acction',
		 		    type:'post',
		 		    dataType:'text',
		 		    // data:JSON.stringify({user:this.user}),  
		 			data:{
						id:this.user.id
		 			},
		 			success:function(msg){
		 		    console.log(msg.data)
		 		  }
		 		})
		 		// this.getUser()
			}
			
			
			
			
		}
		
	})
	
</script>
</body>
</html>